package com.luhongzhe.gameview;

import com.luhongzhe.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

/**
 * @author 	luhongzhe
 * @email  	azhe0660@gmail.com
 * @date   	2011-10-11
 */

public class CommonScene extends Activity implements GameViewHolder
{
	LinearLayout layout;
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		Button mReturnBtn = null;
		
		super.onCreate(savedInstanceState);	
			
		layout = new LinearLayout(this);
		layout.setOrientation(LinearLayout.VERTICAL);
		mReturnBtn = new Button(this);
		mReturnBtn.setText("返回");
		mReturnBtn.setOnClickListener(returnBtnClickListener);

		int gameId = getIntent().getIntExtra("gameId", 0);
		layout.addView(mReturnBtn);
		layout.addView(new FallingBoxsView(this, this));
		setContentView(layout);
	}
	
	private OnClickListener returnBtnClickListener = new OnClickListener()
	{
		@Override
		public void onClick(View v)
		{
//			CommonScene.this.finish();
			CommonScene.this.nextGameView();
		}
	};
	
	private void nextGameView()
	{
		layout.removeViewAt(layout.getChildCount() - 1);
		layout.addView(new FallingBoxsView(this, this));
	}

	@Override
	public void success()
	{
		nextGameView();
	}
	
}
